home *** CD-ROM | disk | FTP | other *** search
/ PCMania 64 / PCMania CD64_1.iso / phy / phy002 / games / tron / tron.asm next >
Encoding:
Assembly Source File  |  1995-03-23  |  2.4 KB  |  155 lines

  1. ;-----------------------------------------------------------
  2. ;
  3. ; TRON - LightCycles - 2player only.... (AI? yeah, right!)
  4. ;
  5. ; Keys: (make sure numlock is on, and capslock is off)
  6. ;
  7. ;         P0    P1
  8. ;
  9. ; up      A     6
  10. ; down    Z     3
  11. ; left    X     1
  12. ; right   C     2
  13. ;
  14. ; Rules: first to crash loses.
  15. ;
  16. ; (going back on yourself constitutes a crash!)
  17. ;
  18. ; Coded in 45 minutes on 23/03/95 by C.H.Skilbeck (henry@prog.demon.co.uk)
  19. ;
  20. ;-----------------------------------------------------------
  21.  
  22. b    equ    byte ptr
  23. w    equ    word ptr
  24. s    equ    short
  25.  
  26. cseg    segment    byte
  27.  
  28.     assume    cs:cseg,ds:cseg,es:nothing,ss:cseg
  29.  
  30.     org    100h
  31.  
  32. start:    mov    ax,13h    ;320x200x256
  33.     int    10h
  34.  
  35.     mov    es,cs:scrnseg    ;es->screen
  36.  
  37.     sub    bx,bx
  38.     mov    cx,320
  39.     mov    ax,cx
  40. @@box:    mov b    es:[bx],3
  41.     mov b    es:[bx+64000-320],3
  42.     inc    bx
  43.     loop    @@box
  44.  
  45.     sub    bx,bx
  46.     mov    cx,200
  47. @@box1:    mov b    es:[bx],3
  48.     mov b    es:[bx+319],3
  49.     add    bx,ax
  50.     loop    @@box1
  51.  
  52. @@loop:    mov    ah,1
  53.     int    16h    ;key there?
  54.     jz s    @@nok
  55.     sub    ah,ah
  56.     int    16h    ;get it
  57.  
  58.     mov    bx,p0vel    ;change p0 velocity
  59.     cmp    al,'a'
  60.     jne s    @@na
  61.     mov    bx,-320
  62. @@na:    cmp    al,'z'
  63.     jne s    @@nz
  64.     mov    bx,320
  65. @@nz:    cmp    al,'x'
  66.     jne s    @@nx
  67.     mov    bx,-1
  68. @@nx:    cmp    al,'c'
  69.     jne s    @@nc
  70.     mov    bx,1
  71. @@nc:    mov    p0vel,bx
  72.  
  73.     mov    bx,p1vel    ;change p1 velocity
  74.     cmp    al,'6'
  75.     jne s    @@na1
  76.     mov    bx,-320
  77. @@na1:    cmp    al,'3'
  78.     jne s    @@nz1
  79.     mov    bx,320
  80. @@nz1:    cmp    al,'1'
  81.     jne s    @@nx1
  82.     mov    bx,-1
  83. @@nx1:    cmp    al,'2'
  84.     jne s    @@nc1
  85.     mov    bx,1
  86. @@nc1:    mov    p1vel,bx
  87.  
  88. @@nok:    mov    bx,p0
  89.     mov b    es:[bx],1    ;trail p0
  90.     add    bx,p0vel    ;move p0
  91.     mov b    al,es:[bx]    ;collision detect p0
  92.     or    al,al
  93.     jnz s    @@p0dies
  94.     mov b    es:[bx],15    ;plot p0
  95.     mov    p0,bx
  96.  
  97.     mov    bx,p1
  98.     mov b    es:[bx],2    ;trail p1
  99.     add    bx,p1vel    ;move p1
  100.     mov b    al,es:[bx]    ;collision p1
  101.     or    al,al
  102.     jnz s    @@p1dies
  103.     mov b    es:[bx],15    ;plot p1
  104.     mov    p1,bx
  105.  
  106.     call    waitvb
  107.  
  108.     jmp    @@loop    ;loop
  109.  
  110. @@p0dies:    mov    bl,1    ;p0 dies
  111.     jmp s    @@fla
  112.  
  113. @@p1dies:    mov    bl,2    ;p1 dies
  114.  
  115. @@fla:    mov    cx,50
  116. @@show:    mov    dx,03c8h    ;fade colour of dead player
  117.     mov    al,bl
  118.     out    dx,al
  119.     inc    dx
  120.     mov    al,cl
  121.     out    dx,al
  122.     out    dx,al
  123.     out    dx,al
  124.     call    waitvb
  125.     loop    @@show
  126.  
  127. @@exit:    mov    ax,3    ;back to text mode
  128.     int    10h
  129.  
  130.     ret
  131.  
  132. waitvb:    push    dx
  133.     mov    dx,3dah
  134. @@w1:    in    al,dx
  135.     test    al,8
  136.     jnz s    @@w1    ;Waitvb
  137. @@w2:    in    al,dx
  138.     test    al,8
  139.     jz s    @@w2
  140.     pop    dx
  141.     ret
  142.  
  143.  
  144. scrnseg    dw    0a000h    ;screen seg address
  145.  
  146. p0    dw    32010    ;p0 addr
  147. p0vel    dw    1    ;p0 vel
  148.  
  149. p1    dw    32000+309    ;p1 addr
  150. p1vel    dw    -1    ;p1 vel
  151.  
  152. cseg    ends
  153.  
  154.     end    start
  155.